/**
 * Created by Vector on 17/7/23.
 */

var fs = require("fs");
var data = "vector && summer love eachother forever.";


// 创建一个可以写入的流，写到文件output.txt中
var writerStream = fs.createWriteStream("output.txt");

// 使用UTF8编码写入数据
writerStream.write(data,"UTF8");

// 标记文件末尾
writerStream.end();

// 处理流事件 --> data、end、 error
writerStream.on("finish",function () {
    console.log("写入完成");
});

writerStream.on("error",function () {
    console.log("写入出错");
});

console.log("程序执行完毕");
